Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Regex having "." (no other special characters) between text it can have many dots with text around but not two dots consecutively "example.one.three"

so I am looking for a regex which disallows two consecutive "." but it can have many. Also the string should not start or end with ".".

I've written a regex but it allows multiple dots consecutively.

new RegExp("^[0-9a-z].*[0-9a-z]$", "i"),

valid examples

"abc.def.hun.asasdsd"
"asasaasass.l"
"p.asasasas"

invalid examples

".asassa"
"sasas..sasas.sas"
"asas.sasas.sasas."
"sasas...sasasdsd.sasass"
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You may use this regex:

/^[a-z\d](?!.*\.\.)(?:.*[a-z\d])?$/gmi

RegEx Demo

Explanation:

  • ^[a-z\d]: Match alphanumeric char at start
  • (?!.*\.\.): Negative lookahead to fail the match if 2 consecutive dots are present anywhere
  • (?:.*[a-z\d])?: Match anything followed by alphanumeric char. Make this an optional group match
  • $: End
about 4 years ago · Juan Pablo Isaza Report

0

You can use this command, to start with ^[0-9a-z] with the number of letters, and then groups of dot with letters and numbers but not two sequential dots.

const result = new RegExp("^[0-9a-z]+?(\.[0-9a-z]+)*$", "i").test('one.dsfsdf.');

console.log(result)

about 4 years ago · Juan Pablo Isaza Report

0

Perhaps this works for your case?

^[0-9a-z]+(\.[0-9a-z]+)*$

Regex101

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!